<template>
    <div class="main">
        <div class="title">
            组织:
            <div class="creat-btn">
                <el-button>
                    <i class="el-icon-plus"></i>
                    加入/创建
                </el-button>
            </div>
        </div>
        <div class="team-box" v-if="joinTeam.length > 0">
            <div class="sub-title">
                我加入的组织
                <div class="creat-btn">
                    <el-button>
                        <i class="el-icon-plus"></i>
                        退出团队
                    </el-button>
                </div>
            </div>
            <div class="team-name">
                <el-avatar size="small"> {{ joinTeam && joinTeam[0].team.teamName.charAt(0) }} </el-avatar>
                <div>
                    {{ joinTeam && joinTeam[0].team.teamName }}
                </div>
            </div>
            <div class="team-desc">
                <div class="desc">
                    团队介绍:
                    <br>
                    <br>
                    {{ joinTeam && joinTeam[0].team.teamDesc }}
                </div>
                <div>
                    团队成员:
                    <br>
                    <br>
                    <div class="member-box">
                        <div class="member" v-for="item in joinTeam && joinTeam[0].team.members">
                            <el-avatar size="small"> m </el-avatar>
                            {{ item.userName }}@{{ item.userPhone }}
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="team-box" v-if="createTeam.length > 0">
            <div class="sub-title">
                我创建的组织
                <div class="creat-btn">
                    <el-button>
                        <i class="el-icon-plus"></i>
                        解散团队
                    </el-button>
                </div>
            </div>
            <div class="team-name">
                <el-avatar size="small"> {{ createTeam[0].team.teamName.charAt(0) }} </el-avatar>
                <div>
                    {{ createTeam[0].team.teamName }}
                </div>
            </div>
            <div class="team-desc">
                <div class="desc">
                    团队介绍:
                    <br>
                    <br>
                    {{ createTeam[0].team.teamDesc }}
                </div>
                <div>
                    团队成员:
                    <br>
                    <br>
                    <div class="member-box">
                        <div class="member" v-for="item in createTeam[0].team.members">
                            <el-avatar size="small"> m </el-avatar>
                            {{ item.userName }}@{{ item.userPhone }}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import { GetTeamMessage } from '../api/TeamApi'
export default {
    data() {
        return {

            createTeam: [],  // 创建的团队
            joinTeam: [] // 加入的团队
        }
    },
    created() {
        this.init()
    },
    methods: {
        init() {
            let data = {
                userId : localStorage.getItem('userId')
            }
                GetTeamMessage(data).then(res => {
                    console.log(res, '9898989898989');
                    this.createTeam = res.data.filter(element => {
                        return element.isCreator === 1
                    })

                    this.joinTeam = res.data.filter(element => {
                        return element.isCreator === 0
                    })
                    console.log('this.createTeam',this.createTeam, 'this.joinTeam', this.joinTeam, );
                })
        }
    }
}

</script>

<style scoped>
.main {
    height: 100%;
    border: 1px solid #E4E7ED;
    background: #F5F5F5;
    border-radius: 10px;
    padding: 10px 20px;
    overflow: hidden;
}

.title {
    display: flex;
    align-items: center;
    font-size: 15px;
}

.creat-btn {
    margin-left: auto;
}

.team-box {
    border-radius: 10px;
    margin-top: 20px;
    background: #fff;
    padding: 10px 20px;
}

.sub-title {
    font-size: 15px;
    display: flex;
    align-items: center;
}

.team-name {
    display: flex;
    align-items: center;
}

.team-name div {
    margin-left: 10px;
    font-size: 13px;
    color: rgb(161, 159, 81)
}

.team-desc {
    display: flex;
    padding: 15px;
    font-size: 15px;
}

.team-desc div {
    flex: 5;
    font-size: 12px;
    text-align: justify;
    margin-right: 15px;

}

.member {
    display: flex;
    align-items: center;
    font-size: 13px !important;
    margin-top: 3px;
}

.desc {
    border-right: 1px solid;
    padding-right: 15px;
}
</style>